'''def f(x=True):
    
    if x:
        print 'xxx'
    else:
        print 'yyy'
    print 'googd'

def fib(n):
    a,b=0,1
    count=1
    while count<n:
        a,b=b,a+b
        count=count+1
    if n==1:
        print 1
    elif n==0:
        print 0
    else:
        print b
            
def foo(num,base):
    if(num>=base):
        foo(num/base,base)
    print num%base
numA=input("A:")
numB=input("B:")
foo(numA,numB)

def fib(n):
    if n==1 or n== 0:
        return n
    else:
        return fib(n-1)+fib(n-2)
'''
def hanoi(a,b,c,n):
    if n==1:
        print a,'->',c
    else:
        hanoi(a,c,b,n-1)
        print a,'->',c
        hanoi(b,a,c,n-1)
        